export type BoolValGetterType = () => boolean

export type BoolValSetterType = () => void

/**
 * 创建一个存储 boolean 类型值及其 getter setter 的对象
 *
 * @returns {{val: boolean, getter: BoolValGetterType, setFalse: BoolValSetterType, setTrue: BoolValSetterType}}
 * 存储 boolean 类型值及其 getter setter 的对象
 */
export const useBool = (): {
  val: boolean
  getter: BoolValGetterType
  setFalse: BoolValSetterType
  setTrue: BoolValSetterType
} => {
  const boolVal = {
    val: false,
    getter: function () {
      return boolVal.val
    },
    setFalse: function () {
      boolVal.val = false
    },
    setTrue: function () {
      boolVal.val = true
    }
  }
  return boolVal
}

export type UseBoolType = typeof useBool
